package chapter03

/**
 * @program lu-scala01
 * @description: 抽象类
 * @author: zhanglu
 * @create: 2022-03-12 14:59:00
 */
object C09_AbstractClass {

  def main(args: Array[String]): Unit = {
    val student09 = new Student09
    student09.eat
    student09.sleep
  }

}

abstract class Person09{
  //非抽象属性
  val name: String = "person"
  //抽象属性
  var age: Int
  //非抽象方法
  def eat: Unit ={
    println("person eat")
  }
  //抽象方法
  def sleep: Unit
}

class Student09 extends Person09 {
  //实现抽象属性
  override var age: Int = 18
  //实现抽象方法
  def sleep: Unit = {
    println("student sleep")
  }
  //重写非抽象属性
  override val name: String = "student"
  //重写非抽象方法
  override def eat: Unit = {
    super.eat
    println("student eat")
  }

}
